library(RSelenium)

login_qqmail = function() {
    qqmail_url = 'https://mail.qq.com/cgi-bin/loginpage?lang=cn'
    remDr = remoteDriver(remoteServerAddr = 'localhost'
                         , port = 4444L
                         , browserName = 'chrome'
    )
    remDr$open()
    remDr$navigate(qqmail_url)
    remDr$switchToFrame('login_frame')
    switchElem = remDr$findElement('id', 'switcher_plogin')
    switchElem$clickElement()
    user_login = remDr$findElement('xpath', "//input[@id='u' and @name='u']")$sendKeysToElement(list('哈哈'))
    user_passwd = remDr$findElement('xpath', "//input[@id='p' and @name='p']")$sendKeysToElement(list('嚯嚯'))
    remDr$findElement(using='id', value='login_button')$clickElement()

    remDr$quit()
}

login_qqmail()
